Attempts to remove an item from the BlockingCollection<(Of <(T>)>).
Namespace:
System.Collections.Concurrent
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Function TryTake ( _
<OutAttribute> ByRef item As T, _
timeout As TimeSpan _
) As Boolean |
C# |
---|
public bool TryTake(
out T item,
TimeSpan timeout
) |
Parameters
- item
- Type:
T
%
The item removed from the collection.
- timeout
- Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds
to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.
Return Value
true if an item could be removed from the collection within
the alloted time; otherwise, false.
Exceptions
Exception | Condition |
---|
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed. |
System..::.ArgumentOutOfRangeException | timeout is a negative number
other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than
MaxValue. |
System..::.InvalidOperationException | The underlying collection was modified
outside of this BlockingCollection<(Of <(T>)>) instance. |
See Also